import glob
import os
import stat
from distutils.core import setup
from distutils.util import convert_path
from gnomeagenda import APP_VERSION

def find_packages(where='.', exclude=()):
    """Return a list all Python packages found within directory 'where'

    'where' should be supplied as a "cross-platform" (i.e. URL-style) path; it
    will be converted to the appropriate local path syntax.  'exclude' is a
    sequence of package names to exclude; '*' can be used as a wildcard in the
    names, such that 'foo.*' will exclude all subpackages of 'foo' (but not
    'foo' itself).
    """
    out = []
    stack=[(convert_path(where), '')]
    while stack:
        where,prefix = stack.pop(0)
        for name in os.listdir(where):
            fn = os.path.join(where,name)
            if ('.' not in name and os.path.isdir(fn) and
                os.path.isfile(os.path.join(fn,'__init__.py'))
            ):
                out.append(prefix+name); stack.append((fn,prefix+name+'.'))
    for pat in list(exclude)+['ez_setup']:
        from fnmatch import fnmatchcase
        out = [item for item in out if not fnmatchcase(item,pat)]
    return out

setup(
	name='gnome-agenda',
	version=APP_VERSION,
	description='A Calendar displaying application written in python and gtk for the gnome2 desktop. It supports ical, GoogleCalendar and Groupwise',
	author='Florian Dorn',
	author_email='florian.dorn@gmail.com',
	url='http://code.google.com/p/gnome-agenda/',
	packages = find_packages('.'),
	license='GPL v2',
	scripts = ['gnome-agenda'],
    data_files=[
                  ('share/applications', ['data/gnome-agenda.desktop']),
                 ],
	package_data={'gnomeagenda': ['gnome-agenda.glade']},


)


